<?php

namespace App\Http\Requests\System\SysLogin;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Enum;
use OpenApi\Attributes as OA;


#[OA\Schema(title: '后台登录表单', required: ['username', 'password'],)]
class LoginRequest extends FormRequest {

    #[OA\Property('username', title: '用户名', type: 'string', example: 'ruoyi')]
    #[OA\Property('password', title: '密码', type: 'string', example: '123456')]
    #[OA\Property('uuid', title: 'uuid', type: 'string', example: '$2y$10$dKJhgqWEzkxo1mDSVRnEferj09veZ7Py2gbt63m5qFcQnEo7ObCa6', description: '获取验证码接口下发')]
    #[OA\Property('code', title: '验证码', type: 'string', example: 'ef81', description: '图片验证码的结果')]
    public function rules() {       /* 'mobile' => 'required|regex:/^1\d{10}$/' */ 
        return [
            'username' => ['required'],
            'password' => ['required', 'min:6'],
            ...(config('admin.admin_catpcha') ? ['uuid' => 'required', 'code' => 'required',] : []),
        ];
    }

    public function attributes() {  /* 'mobile' => '手机号' */ 
        return [
            'username' => '用户账号',
            'password' => '密码',
            'uuid' => 'UUID',
            'code' => '验证码',
        ];
    }

    public function messages() {    /* 'mobile.regex' => '手机号格式不对' */ 
        return [
        ];
    }

}
